import copy

from django.conf import settings
from django.template import Library

register = Library()

@register.inclusion_tag("tag/mobiledj_menu.html")
def mobiledj_menu(request):
    user_menu_list = copy.deepcopy(settings.MOBILEDJ_MENU[request.mobiledj_user.role])
    for item in user_menu_list:
        item['class'] = 'hide'
        for child in item['children']:
            # if child['url'] == request.path_info:
            if child['name'] == request.mobiledj_user.menu_name:
                child['class'] = 'active'
                item['class'] = ''
    return {'user_menu_list': user_menu_list}
